/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.p10.miage.gestionabsence.model;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author huynal
 */
public class AgendaAffichage {
    
    int idAgenda;
    String nomSalle;
    String nomEc;
    String ecDebut;
    String ecFin;
    String gradeFormation;
    String niveauFormation;
    String filiereFormation;
    String parcoursFormation;
    String typeeFormation;

    public AgendaAffichage() {
    }

    public AgendaAffichage(int idAgenda, String nomSalle, String nomEc, String ecDebut, String ecFin, String gradeFormation, String niveauFormation, String filiereFormation, String parcoursFormation, String typeeFormation) {
        this.idAgenda = idAgenda;
        this.nomSalle = nomSalle;
        this.nomEc = nomEc;
        this.ecDebut = ecDebut;
        this.ecFin = ecFin;
        this.gradeFormation = gradeFormation;
        this.niveauFormation = niveauFormation;
        this.filiereFormation = filiereFormation;
        this.parcoursFormation = parcoursFormation;
        this.typeeFormation = typeeFormation;
    }

    public String getEcDebut() {
        return ecDebut;
    }

    public void setEcDebut(String ecDebut) {
        this.ecDebut = ecDebut;
    }

    public String getEcFin() {
        return ecFin;
    }

    public void setEcFin(String ecFin) {
        this.ecFin = ecFin;
    }

    public String getFiliereFormation() {
        return filiereFormation;
    }

    public void setFiliereFormation(String filiereFormation) {
        this.filiereFormation = filiereFormation;
    }

    public String getGradeFormation() {
        return gradeFormation;
    }

    public void setGradeFormation(String gradeFormation) {
        this.gradeFormation = gradeFormation;
    }

    public int getIdAgenda() {
        return idAgenda;
    }

    public void setIdAgenda(int idAgenda) {
        this.idAgenda = idAgenda;
    }

    public String getNiveauFormation() {
        return niveauFormation;
    }

    public void setNiveauFormation(String niveauFormation) {
        this.niveauFormation = niveauFormation;
    }

    public String getNomEc() {
        return nomEc;
    }

    public void setNomEc(String nomEc) {
        this.nomEc = nomEc;
    }

    public String getNomSalle() {
        return nomSalle;
    }

    public void setNomSalle(String nomSalle) {
        this.nomSalle = nomSalle;
    }

    public String getParcoursFormation() {
        return parcoursFormation;
    }

    public void setParcoursFormation(String parcoursFormation) {
        this.parcoursFormation = parcoursFormation;
    }

    public String getTypeeFormation() {
        return typeeFormation;
    }

    public void setTypeeFormation(String typeeFormation) {
        this.typeeFormation = typeeFormation;
    }


    
    public void init(ResultSet resultat) throws SQLException{

        this.idAgenda = resultat.getInt("IDCR");    
        this.nomSalle = resultat.getString("salle");
        this.nomEc = resultat.getString("ec");
        this.ecDebut = resultat.getString("debut");
        this.ecFin = resultat.getString("fin");
        this.ecDebut = transformHoraire(this.ecDebut);
        this.ecFin = transformHoraire(this.ecFin);
        this.gradeFormation = resultat.getString("grade");
        this.niveauFormation = resultat.getString("niveau");
        this.filiereFormation = resultat.getString("filiere");
        this.parcoursFormation = resultat.getString("parcours");
        this.typeeFormation = resultat.getString("typee");
    }
    
        public void initEtudiant(ResultSet resultat) throws SQLException{

        this.idAgenda = resultat.getInt("IDCR");    
        this.nomSalle = resultat.getString("salle");
        this.nomEc = resultat.getString("ec");
        this.ecDebut = resultat.getString("debut");
        this.ecFin = resultat.getString("fin");
        this.ecDebut = transformHoraire(this.ecDebut);
        this.ecFin = transformHoraire(this.ecFin);
    }
    
    private String transformHoraire(String horaire)
    {
        String heure;
        String minute;
        if(horaire.length() == 3)
        {
            heure = horaire.substring(0,1);
            minute = horaire.substring(1,3);
            horaire = heure + "H" + minute;
        }
        else
        {
            heure = horaire.substring(0,2);
            minute = horaire.substring(2,4);
            horaire = heure + "H" + minute;
        }
        return horaire;
    }
       
}
